﻿;
! function() {
	var layer = layui.layer,
		form = layui.form,
		carousel = layui.carousel;

	// 背景图片轮播
	carousel.render({
		elem: '#login_carousel',
		width: '100%',
		height: '100%',
		interval: 3000,
		arrow: 'none',
		anim: 'fade',
		indicator: 'none'
	});

	// 自定义验证规则
	form.verify({
		account: function(value) {
			var regPhone = /^1[34578]\d{9}$/;
			if(!regPhone.test(value.trim())) {
				return "请输入正确的手机号";
			}
		}
	});

	//监听提交  
	form.on("submit(login)", function() {
		var code = $("#drag").text();
		if(code=="拖动滑块验证"){
			layer.msg("请拖动滑块验证",{icon:2})
		}else if(code=="验证通过"){
		$.ajax({
			url: "/GoHome/web/userinfo/login",
			type: "post",
			data: {
				"phone": $("#account").val(),
				"userpass": $("#password").val(),
				"remenberMe":$("#remenberMe").prop("checked")
			},
			success: function(result) {
				if(result=="true"){
					location = "/GoHome/web/index";
				}else if(result=="账户冻结"){
					layer.msg("账户冻结",{icon:2});
				}else if(result=="false"){
                    layer.msg("帐号或密码错误",{icon:2});
                }else{
					location = result;
				}

			}
		});
	}

		return false;
	});
}();